﻿using LiteBlog.Common.Entities;
using LiteBlog.Components.Contracts;
using LiteBlog.Components.Enums;
using LiteBlog.Controllers.Contracts;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace LiteBlog.Controllers.Tests
{
    [TestClass]
    public class AuthorControllerTests : CompControllerTests<Author, string, IAuthorComp, IAuthorController>
    {
        private static readonly string Id = "test";

        [TestMethod]
        public void UnlockWorks()
        {
            var mock = Mock.Get<IAuthorComp>(_controller.GetComponent<IAuthorComp>());
            mock.Setup(au => au.Unlock(It.IsAny<string>())).Returns(MethodResult.UnlockSuccess);
            _controller.Unlock(Id);
            mock.Verify(au => au.Unlock(Id));
        }

        [TestMethod]
        public void MakePrimaryWorks()
        {
            var mock = Mock.Get<IAuthorComp>(_controller.GetComponent<IAuthorComp>());
            mock.Setup(au => au.MakePrimary(It.IsAny<string>())).Returns(MethodResult.PrimarySuccess);
            _controller.MakePrimary(Id);
            mock.Verify(au => au.MakePrimary(Id));
        }

        [TestMethod]
        public void DisableWorks()
        {
            var mock = Mock.Get<IAuthorComp>(_controller.GetComponent<IAuthorComp>());
            mock.Setup(au => au.Disable(It.IsAny<string>(), It.IsAny<bool>())).Returns(MethodResult.EnableSuccess);
            _controller.Disable(Id);
            mock.Verify(au => au.Disable(Id, false));
        }
        
    }
}
